package com.zmp.kotlinnote.exchange

import org.junit.Test
import java.text.SimpleDateFormat

/**
 *@author zmp
 *Created by zmp on 2018/12/19
 */

fun aaa(a: () -> Unit) {
    a()
}

class AAA {
    @Test
    fun method() {
        val a = fun() {
            println("AAAAAAAA")
        }
        aaa(a)

        aaa {
            println("AAAAAAAA")
        }

        aaa(fun():Unit{})
        aaa2(fun(i,j):Int{
            return  i+j
        })

        aaa2{i,j->
            i-j
        }

        aaa2 { i, i2 ->
            i + i2
        }

        aaa2(fun(i: Int, i2): Int {
            return i - i2
        })

        var aaa3 = aaa3(fun(i, j): Int {
            return i + j
        }, 3, 5)
        aaa3.log()
        aaa3({i,j->
            i*j
        },2,4).log()

        aaa3({ i, i2 ->
                i * i2
        }, 2, 3).log()


        aaa3(fun(a, b): Int {
            return a / b
        }, 4, 2).log()

    }


    private fun add(a: Int, b: Int): Int {
        return a + b
    }
}

fun aaa2(block: (Int, Int) -> Int) {
    block(1, 2)
}

fun aaa3(block: (Int, Int) -> Int, a: Int, b: Int): Int {
    return block(a, b)
}

